<input type="hidden" name='url' id='url' value="<?php echo $this->Html->url( '/', true ); ?>">
<section class="content-header">
	<h1>Servicios<small>Listado</small></h1>
	<ol class="breadcrumb">

		<li>
      <?php echo $this->Html->link(
        $this->Html->tag('i', '', array('class' => 'fa fa-dashboard ')) . "Inicio",'/',   
        array('class' => '', 'escape' => false)
        ); 		
      ?> 
		</li>		
		<li class="active">Servicios</li>
	</ol>
</section>

<section class="content">
  <div class="row margin">
    <div class="col-md-6"> 
      <div class="btn-group">
        <?php echo $this->Html->link(__('Nuevo', true), array('controller' => 'services', 'action' => 'add' ),array('class'=>'btn btn-info btn-flat')); ?> 
        <button class='btn btn-info btn-flat' id='edit_bt' >Editar</button>
        <!--<button class='btn btn-info btn-flat' id='delete_bt'>Eliminar</button> -->
      </div>
    </div> 
    <div class="hidden col-md-6">
      <div class="input-group">
      <input class="form-control" type="text">
      <span class="input-group-btn">
      <button class="btn btn-info btn-flat" type="button">Buscar!</button>
      </span>
      </div>
    </div>
  </div>
	<div class="row">
   	<div class="col-md-12">  
   		<div class="box">
        
       	<table class="table table-bordered table-hover">
       		<thead>
       			<tr>
              <th class='center'>#</th>
              <th>Nombre</th>
       				<!--<th>Cantidad</th-->
       				<th>Precio Unitario</th>
       			</tr>
       		</thead>
        	<tbody>
            <?php foreach ($data as $item):?>
              <tr>
                <td><input type="checkbox"  name="services_id[]" value="<?php echo $item['Services']['id']?>"></td>
                <td><?php echo $item['Services']['name']?></td>               
                <!--<td><?php echo $item['Services']['amount']?></td> -->
                 <td><?php echo $item['Services']['unit_price']?> $</td>
              </tr>
            <?php endforeach;?>
            <!--
        		<tr>
                <td>183</td>
                <td>John Doe</td>
                <td>11-7-2014</td>
                <td><span class="label label-success">Approved</span></td>
                <td>Bacon ipsum dolor sit amet salami venison chicken flank fatback doner.</td>
            </tr>
            <tr>
                <td>219</td>
                <td>Jane Doe</td>
                <td>11-7-2014</td>
                <td><span class="label label-warning">Pending</span></td>
                <td>Bacon ipsum dolor sit amet salami venison chicken flank fatback doner.</td>
            </tr>
            <tr>
                <td>657</td>
                <td>Bob Doe</td>
                <td>11-7-2014</td>
                <td><span class="label label-primary">Approved</span></td>
                <td>Bacon ipsum dolor sit amet salami venison chicken flank fatback doner.</td>
            </tr>
            <tr>
                <td>175</td>
                <td>Mike Doe</td>
                <td>11-7-2014</td>
                <td><span class="label label-danger">Denied</span></td>
                <td>Bacon ipsum dolor sit amet salami venison chicken flank fatback doner.</td>
            </tr>-->
        	</tbody>
           
        </table>
    	</div><!-- /.box -->
    </div>
  </div>
</section>

<script type="text/javascript">
  function get_check_id(){
    var result=0;
    $('input[name=services_id\\[\\]]').each(function() {
        if( $(this).is(":checked")){
            var user_id = $(this).val();             
            result =  user_id;
        }
    });
    return result;
  }
  $(function(){
    var url=$("#url").val();
    $("#edit_bt").click(function(){
      chck_id= get_check_id();
      redirect_url=url+"services/edit/"+chck_id
      window.location.replace(redirect_url);
      //console.debug("THES: %o",redirect_url);
      return false;
    });

    $("#delete_bt").click(function(){
      chck_id= get_check_id();
      redirect_url=url+"members/delete/"+chck_id
      window.location.replace(redirect_url);
      //console.debug("THES: %o",redirect_url);
      return false;
    });
  });
</script>